﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
using Dapper.Contrib.Extensions;
using DapperExtensions.Mapper;

namespace MaximServices.Model
{
    public class Sysuser
    {
        public string Id { get; set; }

        public string UserName { get; set; }

        public string UserRole { get; set; }

        public DateTime CreateTime { get; set; }

        public DateTime ModifyTime { get; set; }
    }

    public class SysuserMapper : ClassMapper<Sysuser>
    {
        public SysuserMapper()
        {
            //use different table name
            Table("sysuser");

            //use a custom schema
            Schema("");

            //have a custom primary key
            Map(x => x.Id).Column("id").Key(KeyType.Assigned);

            Map(x => x.UserName).Column("user_name");
            Map(x => x.UserRole).Column("user_role");
            Map(x => x.CreateTime).Column("create_time");
            Map(x => x.ModifyTime).Column("modify_time");

            //optional, map all other columns
        }
    }
}
